package com.winteam.View;



import com.winteam.Bean.Admin;
import com.winteam.Bean.Des;
import com.winteam.Bean.RoomInfo;
import com.winteam.Bean.RoomType;
import com.winteam.Controler.RoomSelect;
import com.winteam.Controler.Select;
import com.winteam.Controler.Updata;
import com.winteam.Controler.UserSelect;
import com.winteam.dao.DbConnection;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.Vector;

/*
系统管理模块
 */
public class Operator extends JFrame {
    Select select =new Select();
    Updata updata = new Updata();
    private JTextField textField;
    private JPasswordField passwordField;
    private JPasswordField passwordField_1;
    private JPasswordField passwordField_2;
    private JTextField textField_1;
    private JTextField textField_2;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_5;
    private JTextField textField_6;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTable table_2;
    private JTable table_4;
    private JTable table;
    private JTable table_1;
    private JTable table_3;
    // 数据模型
    DefaultTableModel roomDT = new DefaultTableModel();
            //字体的设置

    Font font = new Font("宋体",Font.PLAIN,15);

    private RoomType roomType = new RoomType();
      private  Color color = new Color(231, 215, 183);


    private RoomType roomInfo = new RoomType();
    private RoomInfo  room = new RoomInfo();
    private Admin admininfo = new Admin();

    public Operator(Admin a){
    super("系统设置");
    a=admininfo;
        this.setBounds(0, 0, 900, 605);
        this.setLocationRelativeTo(null);//居中显示
        this.setResizable(true);//设置用户不可改变大小
        JTabbedPane tabbedPane=new JTabbedPane();
        tabbedPane.setBounds(0, 0, 880,550);
        getContentPane().add(tabbedPane);

        JPanel p1 = new JPanel();//主控制面
        tabbedPane.addTab("房间项目设置",new ImageIcon(this.getClass().getResource("img//u01.gif")), p1);

        JComboBox cmb = new JComboBox(); //状态
        cmb.setBounds(231, 7, 150, 24);
        cmb.setFont( font);
        cmb.addItem("可供状态");
        cmb.addItem("不可供状态");
        cmb.addItem("打扫状态");
        JLabel label_24 = new JLabel("结账后房间状态变为：");
        label_24.setBounds(61, 8, 171, 18);
        label_24.setFont(font);
        p1.add(label_24);
        cmb.setVisible(true);
        p1.setLayout(null);
        p1.add(cmb);


        JLabel label_25 = new JLabel("结账后");
        label_25.setBounds(394, 10, 72, 18);
        label_25.setFont(font);
        p1.add(label_25);

        textField_8 = new JTextField();
        textField_8.setBounds(450, 7, 35, 24);
        p1.add(textField_8);
        textField_8.setColumns(10);

        JLabel label_27 = new JLabel("后分钟后变为可使用状态");
        label_27.setBounds(499, 10, 179, 18);
        label_27.setFont(font);
        p1.add(label_27);

        ImageIcon roomIcon=new ImageIcon(this.getClass().getResource("img//save.gif"));
        JButton button_7 = new JButton("保存",roomIcon);
        button_7.setBounds(704, 6, 113, 27);
        button_7.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
            }
        });
        button_7.setFont(font);
        p1.add(button_7);

        JLabel label_28 = new JLabel("房间类型");
        label_28.setFont(new Font("黑体",Font.BOLD,16));
        label_28.setBounds(14, 39, 120, 20);
        p1.add(label_28);


        JButton button_8 = new JButton("添加类型");
        button_8.setBounds(200, 234, 133, 27);
        button_8.setFont(font);
//        button_8.setBackground(new Color(231, 215, 183));
        button_8.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                AddRoomType addRoomType = new AddRoomType();
                addRoomType.setVisible(true);
            }
        });
        button_8.setIcon(new ImageIcon(this.getClass().getResource("img//new.gif")));
        p1.add(button_8);
    //四个按钮的设置
        JButton button_9 = new JButton("修改类型");
        button_9.setBounds(357, 234, 133, 27);
        button_9.setFont(font);
//        button_9.setBackground(new Color(231, 215, 183));
        button_9.setIcon(new ImageIcon(this.getClass().getResource("img//modi0.gif")));
        p1.add(button_9);

        button_9.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (table_1.getSelectedColumn()<0) {
                    JOptionPane.showMessageDialog(null, "未选中");
                }else {
                    UNalterRoomType ulrt = new UNalterRoomType(roomType);
                    ulrt.setVisible(true);
                }
            }
        });

        JButton button_10 = new JButton("删除类型");
        button_10.setBounds(502, 234, 133, 27);
        button_10.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int row = table_1.getSelectedRow() ;
                if (table_1.getSelectedColumn()==-1) {
                    JOptionPane.showMessageDialog(null, "请选择要删除的数据！");
                }else {

                    int result = JOptionPane.showConfirmDialog(null,"注意，删除【房间类型】操作将会于【房间类型】相关的所有【房间信息】一并删除。您确定要删除在表格中选中的类型条目吗？","提示",0,1);

                    if(result == JOptionPane.OK_OPTION){

                      //要删除的房间类型id
                        int id =roomType.getId();
                        roomDT.removeRow(table_1.getSelectedRow());
                            //1.先删除所有房间 类似属于这个的
                        String sql ="delete from room_info   where r_type = "+id+"";
                        DbConnection.updataInfo(sql);
                                    //在删除房间类型
                                String sqlromm="delete from r_tpye_info   where id = "+id+"";
                            if (  DbConnection.updataInfo(sqlromm)){
                                JOptionPane.showMessageDialog(null,"删除成功");

                        }else {
                            JOptionPane.showMessageDialog(null,"删除失败");
                        }

                    }

                }
            }
        });
        ImageIcon i3 = new ImageIcon(this.getClass().getResource("img/refurbish.gif"));
        JButton sx = new JButton("   刷      新",i3);
        sx.setBounds(650, 234, 110, 30);
        sx.setFocusPainted(false);//去掉按钮周围的焦点框
        sx.setContentAreaFilled(false);//设置按钮透明背景
        getContentPane().add(sx);
        sx.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Operator m = new Operator(admininfo);
                dispose();
                m.setVisible(true);
                JOptionPane.showMessageDialog(null, "刷新成功！");
            }
        });
        button_10.setFont(font);
//        button_10.setBackground(new Color(231, 215, 183));
        button_10.setIcon(new ImageIcon(this.getClass().getResource("img//del.gif")));
        p1.add(button_10);
        p1.add(sx);

        JLabel label_29 = new JLabel("按房间类型过滤 ：");
        label_29.setBounds(14, 279, 127, 18);
        p1.add(label_29);


        JComboBox comboBox = new JComboBox();
        comboBox.setBounds(143, 276, 190, 24);
        comboBox.setFont(font);
        List<String> roomlx = select.getRoomlx();
        Vector<String> roomlxs = new Vector<>();
        roomlxs.add("显示查询全部信息");
        for (String s : roomlx) {
            roomlxs.add("显示全部"+s);
        }
        comboBox.setModel(new DefaultComboBoxModel(roomlxs));
        p1.add(comboBox);

        JButton button_12 = new JButton("筛选");
        button_12.setBounds(345, 274, 113, 27);

        button_12.setFont(font);
//        button_12.setBackground(new Color(231, 215, 183));
        button_12.setIcon(new ImageIcon(this.getClass().getResource("img//choose1.gif")));
        p1.add(button_12);
        //根据房间号查询
        JLabel serche = new JLabel("根据房间号查询 :");
        serche.setBounds(480,274,100,27);
        p1.add(serche);
// 搜索框
        JTextField serch = new JTextField();
        serch.setBounds(585,274,150,27);
        p1.add(serch);
        JButton serchbth = new JButton("筛选");
        serchbth.setBounds(740, 274, 113, 27);
        serchbth.setFont(font);
        serchbth.setIcon(new ImageIcon(this.getClass().getResource("img//choose1.gif")));
        p1.add(serchbth);
        JButton button_13_1 = new JButton("添加房间");
        button_13_1.setBounds(159, 477, 127, 27);
        button_13_1.setFont(font);
//        button_13_1.setBackground(new Color(231, 215, 183));
        button_13_1.setIcon(new ImageIcon(this.getClass().getResource("img\\new.gif")));
        p1.add(button_13_1);

        button_13_1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                BatchAddRoom bar=new BatchAddRoom();
                bar.setVisible(true);

            }
        });


        JButton button_13_2 = new JButton("删除房间");
        button_13_2.setBounds(347, 477, 133, 27);

        button_13_2.setFont(font);
//        button_13_2.setBackground(new Color(231, 215, 183));
        button_13_2.setIcon(new ImageIcon(this.getClass().getResource("img\\refurbish.gif")));
        p1.add(button_13_2);




        JButton button_13_3 = new JButton("修改房间");
        button_13_3.setBounds(551, 477, 127, 27);
        button_13_3.setFont(font);
//        button_13_3.setBackground(new Color(231, 215, 183));
        button_13_3.setIcon(new ImageIcon(this.getClass().getResource("img\\modi0.gif")));
        p1.add(button_13_3);



        JScrollPane scrollPane_2 = new JScrollPane();
        scrollPane_2.setBounds(24, 70, 837, 151);
        p1.add(scrollPane_2);

        Vector<String> heads = new Vector<>();
        heads.add("房间类型id");
        heads.add("房间类型");
        heads.add("房间单价");
        heads.add("钟点价格/小时");
        heads.add("床位数量");
        Vector<Vector<Object>> body = new Vector<Vector<Object>>();
        List<RoomType> date = RoomSelect.getRoomType();
        for(RoomType r :date){
            Vector<Object> v = new Vector<>();
            v.add(r.getId());
            v.add(r.getRoom_type());
            v.add(r.getR_price());
            v.add(r.getR_hprice());
            v.add(r.getR_bed());
            body.add(v);
        }
        roomDT=new DefaultTableModel(body,heads);
        table_1 = new JTable(roomDT);

        scrollPane_2.setViewportView(table_1);
        /**
         * 表格监听roomType属性
         */
        table_1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int row = table_1.getSelectedRow();
                roomType.setId(Integer.valueOf(table_1.getValueAt(row,0).toString()));
                roomType.setRoom_type(table_1.getValueAt(row, 1).toString());
                roomType.setR_price(Integer.valueOf(table_1.getValueAt(row, 2).toString()));
                roomType.setR_hprice(Integer.parseInt(table_1.getValueAt(row, 3).toString()));
                roomType.setR_bed(Integer.parseInt(table_1.getValueAt(row, 4).toString()));

            }
        });


        //房间信息表
        JScrollPane scrollPane_3 = new JScrollPane();//添加框架
        scrollPane_3.setBounds(14, 310, 837, 151);
        p1.add(scrollPane_3);
        Vector<String> roomInfoHead = new Vector<>();
        roomInfoHead.add("房间号");
        roomInfoHead.add("房间类型");
        roomInfoHead.add("房间状态");
        roomInfoHead.add("钟点价格/小时");
        roomInfoHead.add("床位数量");
        List<RoomInfo>roomInfoBody= RoomSelect.getRoomInfo();
        Vector<Vector<Object>> roomInfodate = new Vector<>();
        for (RoomInfo roomInfo : roomInfoBody) {
            Vector<Object> v = new Vector<>();
            v.add(roomInfo.getR_rommber());
            v.add(roomInfo.getR_type());
            v.add(roomInfo.getR_state());
            v.add(roomInfo.getR_price());
            v.add(roomInfo.getR_bednumber());
            roomInfodate.add(v);
        }
        DefaultTableModel roomInfoDT=new DefaultTableModel(roomInfodate,roomInfoHead);
        table_3 = new JTable(roomInfoDT);
        table_3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        table_3.getTableHeader().setReorderingAllowed(false);
        table_3.setSelectionBackground(Color.GRAY);

        table_1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        table_1.getTableHeader().setReorderingAllowed(false);
        table_1.setSelectionBackground(Color.GRAY);
        scrollPane_3.setViewportView(table_3);
        /**
         * 表格监听 设置room 属性
         */
        table_3.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int row = table_3.getSelectedRow();
                String roomInfoId =(table_3.getValueAt(row, 0).toString());
               String setRoomType =(table_3.getValueAt(row, 1).toString());
                String roomstate=table_3.getValueAt(row, 2).toString();
                int bed= Integer.parseInt(table_3.getValueAt(row, 3).toString());
               int price =Integer.parseInt(table_3.getValueAt(row, 4).toString());
               room = new RoomInfo(roomInfoId,setRoomType,roomstate,bed,price);
                System.out.println(room);
            }
        });
        /**
         * 查找筛选的按钮 事件
         */
        button_12.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                String selectedItem =(String) comboBox.getSelectedItem();
                Vector<Vector<Object>> newroomInfodate = new Vector<>();
                String selecs = selectedItem.substring(selectedItem.indexOf("部")+1);
                System.out.println(selecs);
                if (selecs.equals("信息")){
                    List<RoomInfo>roomInfoBody= RoomSelect.getRoomInfo();
                    Vector<Vector<Object>> roomInfodate = new Vector<>();
                    for (RoomInfo roomInfo : roomInfoBody) {
                        Vector<Object> v = new Vector<>();
                        v.add(roomInfo.getR_rommber());
                        v.add(roomInfo.getR_type());
                        v.add(roomInfo.getR_state());
                        v.add(roomInfo.getR_price());
                        v.add(roomInfo.getR_bednumber());
                        roomInfodate.add(v);
                    }
                    roomInfoDT.setDataVector(roomInfodate,roomInfoHead);
                    return;
                }
                    List<RoomInfo> roomInfos = select.selecRoomTypeinfo(selecs);
                    for (RoomInfo info : roomInfos) {
                        Vector<Object> v = new Vector<>();
                        v.add(info.getR_rommber());
                        v.add(info.getR_type());
                        v.add(info.getR_state());
                        v.add(info.getR_price());
                        v.add(info.getR_bednumber());
                        newroomInfodate.add(v);
                    }
                    roomInfoDT.setDataVector(newroomInfodate,roomInfoHead);


            }
        });
        /**
         * 搜索框查询
         */
        serchbth.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                Vector<Vector<Object>> newroomInfodate = new Vector<>();
                List<RoomInfo> roomInfos = select.findRoomByRoomber(serch.getText());
                for (RoomInfo info : roomInfos) {
                    Vector<Object> v = new Vector<>();
                    v.add(info.getR_rommber());
                    v.add(info.getR_type());
                    v.add(info.getR_state());
                    v.add(info.getR_price());
                    v.add(info.getR_bednumber());
                    newroomInfodate.add(v);
                }
                roomInfoDT.setDataVector(newroomInfodate,roomInfoHead);
            }
        });
        /**
         * 删除按钮的事件
         */
        button_13_2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = table_3.getSelectedRow();//要移除的行
          int result=   JOptionPane.showConfirmDialog(null,"你确定要删除该房间吗","提示",0,1);
                if (result== JOptionPane.OK_OPTION) {
                    String str =(String)table_3.getValueAt(row,0); // 要删除的房间号码

                if (updata.deleteRoomInfoByRoomNumer(str)) {
                    roomInfoDT.removeRow(row);
                    JOptionPane.showMessageDialog(null,"删除成功");
                }
                }
            }
        });
        //修改按钮额的操作

        button_13_3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                BatchChagerRoom r = new BatchChagerRoom(room);
                r.setVisible(true);
            }
        });

        /**
         * 操作员设置面版
         */
        String[] userHead= {"操作员类型","操作员账号"};
        Object[][] userBody= UserSelect.geUserInfo();
        DefaultTableModel userDt=new DefaultTableModel(userBody,userHead);
        JTable jTable=new JTable(userDt);
        JScrollPane jll=new JScrollPane(jTable);
        jll.setBounds(14, 13, 847, 238);
        jll.setVisible(true);

        jTable.setFont(new Font("Menu.font", Font.PLAIN, 21));
        jTable.setRowHeight(23);
        jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jTable.getTableHeader().setReorderingAllowed(false);
        jTable.setSelectionBackground(Color.lightGray);
        //操作员表添加监控事件
        jTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int row = jTable.getSelectedRow();
                textField.setText(jTable.getValueAt(row, 1).toString());
            }
        });


        JPanel p3=new JPanel() ;//面板组件容器
//		p3.setBackground(new Color(231, 215, 183));
        p3.setLayout(null);
        p3.add(jll);
        tabbedPane.addTab("操作员面板",new ImageIcon(this.getClass().getResource("img\\u03.gif")), p3);
        JLabel label = new JLabel("详细信息");
        label.setFont(new Font("微软雅黑", Font.PLAIN, 17));
        label.setBounds(14, 279, 72, 18);
        p3.add(label);

        JLabel label_1 = new JLabel("用户名 :");
        label_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        label_1.setBounds(40, 310, 72, 18);
        p3.add(label_1);

        textField = new JTextField();//操作员用户名文本框
        textField.setBounds(108, 307, 173, 24);
        p3.add(textField);
        textField.setColumns(10);

        JLabel label_2 = new JLabel("原密码 :");
        label_2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        label_2.setBounds(40, 347, 72, 18);
        p3.add(label_2);

        JLabel label_3 = new JLabel("新密码");
        label_3.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        label_3.setBounds(40, 378, 72, 18);
        p3.add(label_3);

        JLabel label_4 = new JLabel("确认密码");
        label_4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        label_4.setBounds(29, 415, 83, 18);
        p3.add(label_4);

        passwordField = new JPasswordField();
        passwordField.setBounds(108, 341, 173, 24);
        p3.add(passwordField);

        passwordField_1 = new JPasswordField();
        passwordField_1.setBounds(108, 375, 173, 24);
        p3.add(passwordField_1);

        passwordField_2 = new JPasswordField();
        passwordField_2.setBounds(108, 412, 173, 24);
        p3.add(passwordField_2);



        JLabel label_6 = new JLabel("设置操作权限");
        label_6.setFont(new Font("微软雅黑", Font.PLAIN, 17));
        label_6.setBounds(337, 357, 120, 21);
        p3.add(label_6);

        JRadioButton radioButton_3 = new JRadioButton("普通操作员    ");
        radioButton_3.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        radioButton_3.setBounds(365, 397, 157, 27);
        p3.add(radioButton_3);



        JRadioButton radioButton_4 = new JRadioButton("超级管理员");
        radioButton_4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        radioButton_4.setBounds(557, 397, 157, 27);

        ButtonGroup caozuo = new ButtonGroup();
        caozuo.add(radioButton_3);
        caozuo.add(radioButton_4);

        p3.add(radioButton_4);

        JButton button = new JButton("添加");
        button.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        button.setIcon(new ImageIcon(this.getClass().getResource("img\\new.gif")));
//		button.setBackground(new Color(231, 215, 183));
        button.setBounds(180, 478, 113, 27);
        p3.add(button);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (passwordField_2.getText().equals("")||textField.getText().equals("")) {
                    JOptionPane.showMessageDialog(null,"请添加数据！");
                    return;
                }
                String username = textField.getText();
                String pwd1 = new String(passwordField_1.getPassword());
                String pwd2 = new String(passwordField_2.getPassword());
                if (pwd2.equals("")||pwd1.equals("")){
                    JOptionPane.showMessageDialog(null,"请输入数据");
                    return;
                }
                if(pwd2.equals(pwd1)!=true){
                    JOptionPane.showMessageDialog(null,"两次输入的密码不一致");
                    return;
                }
                String a_type = " ";
                if(radioButton_3.isSelected()){
                    a_type ="普通操作员";
                }else if (radioButton_4.isSelected()){
                    a_type= "超级管理员";
                }else {
                    JOptionPane.showMessageDialog(null,"请选择操作权限!!");
                    return;
                }
                //添加数据
                if (updata.Addadmin(username,pwd1,a_type)) {
                    JOptionPane.showMessageDialog(null,"添加成功!!");
                }
            }
        });



        JButton button_1 = new JButton("修改");
        button_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String username =textField.getText();
                String lodpwd = new String(passwordField.getPassword());
                System.out.println(lodpwd);
                String pwd1 = new String(passwordField_1.getPassword());
                String pwd2 = new String(passwordField_2.getPassword());
                if (lodpwd.equals("")||pwd2.equals("")||pwd1.equals("")){
                    JOptionPane.showMessageDialog(null,"请输入数据");
                    return;
                }
                if (pwd1.equals(lodpwd)){
                    JOptionPane.showMessageDialog(null,"原密码和修改密码一样");
                    return;
                }
              if(pwd2.equals(pwd1)!=true){
                  JOptionPane.showMessageDialog(null,"两次输入的密码不一致");
                  return;
              }
              String a_type = " ";
                if(radioButton_3.isSelected()){
                    a_type ="普通操作员";
                }else if (radioButton_4.isSelected()){
                    a_type= "超级管理员";
                }else {
                    JOptionPane.showMessageDialog(null,"请选择操作权限!!");
                    return;
                }
              //先查询 输入的密码是否和数据库的密码相同 如果不相同就放回
                if (select.fintAdminPwd(username,lodpwd)) {

                    //到这里密码就是对的
                    if (updata.updaAdminPwd(username,pwd1,a_type)) {

                        JOptionPane.showMessageDialog(null,"修改密码成功!!");
                    }else {
                        JOptionPane.showMessageDialog(null,"修改密码失败!!");

                    }
                }else {
                    JOptionPane.showMessageDialog(null,"原密码输入错误!!");
                }
//

            }
        });
        button_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
//		button_1.setBackground(new Color(231, 215, 183));
        button_1.setIcon(new ImageIcon(this.getClass().getResource("img\\key.gif")));
        button_1.setBounds(337, 478, 113, 27);
        p3.add(button_1);

        JButton button_2 = new JButton("删除");
        button_2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)  {
              String deletName = textField.getText();
                System.out.println(deletName);
                int result=   JOptionPane.showConfirmDialog(null,"你确定要删除该用户吗?","提示",0,1);

                if (result==JOptionPane.OK_OPTION){
                    if (updata.updateAdminByName(deletName)) {
                        JOptionPane.showMessageDialog(null,"删除成功");
                    }
                }
            }
        });
        button_2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        button_2.setIcon(new ImageIcon(this.getClass().getResource("img\\del.gif")));
//		button_2.setBackground(new Color(231, 215, 183));
        button_2.setBounds(501, 478, 113, 27);
        p3.add(button_2);



        JPanel p4=new JPanel() ;
        /** 面板组件容器 */

        p4.setLayout(null);
//        p4.add(jll);
        tabbedPane.addTab("数据展示",new ImageIcon(this.getClass().getResource("img\\u02.gif")), p4);
        ChartPanel chartPanel = showDate();
        chartPanel.setBounds(80,10 ,600 ,500);
        p4.add(chartPanel);
    }

    public static void main(String[] args) {
        Admin admin = new Admin();
        admin.setPwd("123");
        admin.setUsername("admin");
        new Operator(admin).setVisible(true);
    }
    /** 展示数据的方法 */
    public ChartPanel showDate(){
        ChartPanel frame1;
        CategoryDataset dataset =getDataSet();
        JFreeChart chart = ChartFactory.createBarChart3D(
                "年度月份金额", // 图表标题
                "", // 目录轴的显示标签
                "总金额", // 数值轴的显示标签
                dataset, // 数据集
                PlotOrientation.VERTICAL, // 图表方向：水平、垂直
                true,           // 是否显示图例(对于简单的柱状图必须是false)
                false,          // 是否生成工具
                false           // 是否生成URL链接
        );
        //从这里开始
        CategoryPlot plot=chart.getCategoryPlot();//获取图表区域对象
        CategoryAxis domainAxis=plot.getDomainAxis();         //水平底部列表
        domainAxis.setLabelFont(new Font("黑体",Font.BOLD,14));         //水平底部标题
        domainAxis.setTickLabelFont(new Font("宋体",Font.BOLD,12));  //垂直标题
        ValueAxis rangeAxis=plot.getRangeAxis();//获取柱状
        rangeAxis.setLabelFont(new Font("黑体",Font.BOLD,15));
        chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
        chart.getTitle().setFont(new Font("宋体",Font.BOLD,20));//设置标题字体
        //到这里结束，虽然代码有点多，但只为一个目的，解决汉字乱码问题
       return frame1=new ChartPanel(chart,true);
    }
    /** 展示数据的方法 */
    private static CategoryDataset getDataSet() {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        for (Des data : new Select().findDatas()) {
            dataset.addValue(Integer.valueOf(data.getMoney()), data.getMonth(),"月份");
        }

        return dataset;
    }


}
